import {HttpClient, HttpParams} from '@angular/common/http';
import { Injectable } from '@angular/core';

/*
  Generated class for the JidihttpProvider provider.

  See https://angular.io/guide/dependency-injection for more info on providers
  and Angular DI.
*/
@Injectable()
export class JidihttpProvider {
  constructor(public http: HttpClient) {
  }
  getHotjidi(page:number) {
    let hotMoviesUrl: string = "/photo";
    return this.http.get(hotMoviesUrl+"/weChatApi/science/list?page="+page+"&m="+Math.random());
  }
  getHotjidiinfo(uuid:string){
    let hotjidiInfoUrl: string = "/photo";
    return this.http.get(hotjidiInfoUrl+"/weChatApi/science/info?id="+uuid+"&m="+Math.random());
  }

  /** banner **/
  getBannerHttp(page:number){
    let hotMoviesUrl: string = "/photo";
    return this.http.get(hotMoviesUrl+"/weChatApi/headline/list?page="+page+"&m="+Math.random());
  }

  /** 博主请求 **/
  getBozhuHttp(page:number){
    let hotMoviesUrl: string = "/photo";
    return this.http.get(hotMoviesUrl+"/weChatApi/champio/list?page="+page+"&m="+Math.random());
  }

  getBozhuHttpByName(page:number,name:string){
    if(name==""){
      return this.getBozhuHttp(page);
    }
    let hotMoviesUrl: string = "/photo";
    return this.http.get(hotMoviesUrl+"/weChatApi/champio/list?page="+page+"&name="+name+"&m="+Math.random());
  }
  getBozhuInfoHttp(uuid:string){
    let hotjidiInfoUrl: string = "/photo";
    return this.http.get(hotjidiInfoUrl+"/weChatApi/champio/info?id="+uuid+"&m="+Math.random());
  }

  /** 百科讲堂 **/
  getBaikeJIangtangHttp(page:number){
    let hotMoviesUrl: string = "/photo";
    return this.http.get(hotMoviesUrl+"/weChatApi/wikipedia/list?page="+page+"&m="+Math.random());
  }
  getBaikeJIangtangInfoHttp(uuid:string){
    let hotMoviesUrl: string = "/photo";
    return this.http.get(hotMoviesUrl+"/weChatApi/wikipedia/info?id="+uuid+"&m="+Math.random());
  }
  /** 进行中活动信息 **/
  getHuodongDoingHttp(){
    let hotMoviesUrl: string = "/photo";
    return this.http.get(hotMoviesUrl+"/weChatApi/activity/processing?m="+Math.random());
  }
  /** 活动信息 **/
  getHuodongHttp(page:number){
    let hotMoviesUrl: string = "/photo";
    return this.http.get(hotMoviesUrl+"/weChatApi/activity/list?page="+page+"&m="+Math.random());
  }
  getHuodongInfoHttp(uuid:string){
    let hotMoviesUrl: string = "/photo";
    return this.http.get(hotMoviesUrl+"/weChatApi/activity/info?id="+uuid+"&m="+Math.random());
  }

  /** 是否登陆请求 **/
  getLoginType(){
    let hotMoviesUrl: string = "/photo";
    return this.http.get(hotMoviesUrl+"/weChatApi/getNickname?m="+Math.random());

  }
  /** 如果没有信息 调用callback **/
  getWeiXinCallbackCode(){
    let hotMoviesUrl: string = "/photo";
    return this.http.get(hotMoviesUrl+"/weChatApi/callBack?m="+Math.random());

  }
  /** 获取用户信息 **/
  getUserInfo(){
    let hotMoviesUrl: string = "/photo";
    return this.http.get(hotMoviesUrl+"/weChatApi/authc/userInfo/getUserInfo?m="+Math.random());

  }
  /** 修改用户信息 **/
  changeUserInfo(panner:any){
    let hotMoviesUrl: string = "/photo";
    return this.http.post(hotMoviesUrl+"/weChatApi/authc/userInfo/updateUserInfo",this.encodeHttpParams(panner));

  }

  /**
   * 作品
   */
  getZuoPin(page:number,oderby:string,type:string){
    let hotMoviesUrl: string = "/photo";
    return this.http.get(hotMoviesUrl+"/weChatApi/worksdetails/list?page="+page+"&orderBy="+oderby+"&type="+type+"&m="+Math.random());

  }

  /**
   * 我的作品
   */
  getWodeZuopin(page:number){
    let hotMoviesUrl: string = "/photo";
    return this.http.get(hotMoviesUrl+"/weChatApi/authc/worksdetails/mylist?page="+page+"&m="+Math.random());
  }

  /**
   * 删除作品
   */
  deleteZuopin(id:number){

    let hotMoviesUrl: string = "/photo";
    return this.http.get(hotMoviesUrl+"/weChatApi/authc/worksdetails/delete/"+id);

  }



  private encodeHttpParams(params: any): any {
    if (!params) return null;
    return new HttpParams({fromObject: params});
  }


  /** 用户登陆 **/
  userLoginHome(panner:any){
    let hotMoviesUrl: string = "/photo";
    return this.http.post(hotMoviesUrl+"/weChatApi/userNameLogin?m="+Math.random(),this.encodeHttpParams(panner));

  }

  /**作品详情**/
  getZuoPinInfoHome(zuipinid:string){
    let hotMoviesUrl: string = "/photo";
    return this.http.get(hotMoviesUrl+"/weChatApi/worksdetails/get/"+zuipinid+"?m="+Math.random());

  }

  /** 点赞 **/
  dianZanClick(worksDetailsId:string){
    let hotMoviesUrl: string = "/photo";
    return this.http.get(hotMoviesUrl+"/weChatApi/authc/worksdetails/addGiveLike/"+worksDetailsId+"?m="+Math.random());

  }

  /** huifu **/
  huiFuClick(worksDetailsId:string){
    let hotMoviesUrl: string = "/photo";
    return this.http.get(hotMoviesUrl+"/weChatApi/worksdetails/getReplyDetails/"+worksDetailsId+"?m="+Math.random());

  }
  /** leizhuhuifu **/
  leizhuhuiFuClick(worksDetailsId:string){
    let hotMoviesUrl: string = "/photo";
    return this.http.get(hotMoviesUrl+"/weChatApi/worksdetails/getChampionReply/"+worksDetailsId+"?m="+Math.random());

  }

  /** huifu **/
  getLeizhuIdBuUId(uid:string){
    let hotMoviesUrl: string = "/photo";
    return this.http.get(hotMoviesUrl+"/weChatApi/champio/infoByUid?uid="+uid+"&m="+Math.random());

  }

  /** 回复评论 **/
  huiFuMessage(a:string,b:string,c:string,d:string,e:string){
    var params = {
      "content":c,
      "model":e
    };
    let hotMoviesUrl: string = "/photo";
    return this.http.post(hotMoviesUrl+"/weChatApi/authc/worksdetails/addReplyDetails/"+d+"_"+a+"?m="+Math.random(),this.encodeHttpParams(params));

  }

  /** 评论 **/
  pingLunMessage(a:string,b:string){
    var params = {
      "content":b
    };
    let hotMoviesUrl: string = "/photo";
    return this.http.post(hotMoviesUrl+"/weChatApi/authc/worksdetails/addReplyDetails/"+a+"_0"+"?m="+Math.random(),this.encodeHttpParams(params));

  }
  /*pingLunMessage(pannerr:any){
    let hotMoviesUrl: string = "/photo";
    return this.http.post(hotMoviesUrl+"/weChatApi/authc/worksdetails/addReplyDetails",this.encodeHttpParams(pannerr));

  }*/


}
